package br.usp.pcs.basys2.engine;

import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;

import br.usp.pcs.basys2.Activity;
import br.usp.pcs.basys2.ActivityDuty;
import br.usp.pcs.basys2.DutyGenerator;
import br.usp.pcs.basys2.info.ProcessInfo;

public final class SimpleGenerator implements DutyGenerator {
	
		public SortedSet<ActivityDuty> produceDuties(ProcessInfo processInfo) {
			TreeSet<ActivityDuty> set = new TreeSet<ActivityDuty>();
			List<Activity> allActivities = processInfo.getAllActivities();
			Integer totalTime = processInfo.getCpuTotalTime();
			int inc = totalTime/(allActivities.size()+1);
			int actual = inc ;
			for (Activity activity : allActivities ) {
				ActivityDuty duty = new ActivityDuty();
				duty.setActivity(activity);
				duty.setStartTime(actual);
				set.add(duty);
				actual += inc;
			}
			return set;
		}
	}